/**
 * Copyright (c) 2010 CWI Amsterdam and others. All rights reserved.
 * This program and the accompanying materials are made available
 * under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     CWI Amsterdam - initial API and implementation
 *
 * $Id$
 */
package nl.cwi.arne.provider;


import java.util.Collection;
import java.util.List;

import nl.cwi.arne.Network;

import nl.cwi.arne.factory.ArneFactory;
import nl.cwi.arne.factory.ArnePackage;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.ResourceLocator;

import org.eclipse.emf.ecore.EStructuralFeature;

import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;

/**
 * This is the item provider adapter for a {@link nl.cwi.arne.Network} object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class NetworkItemProvider
	extends ItemProviderAdapter
	implements
		IEditingDomainItemProvider,
		IStructuredItemContentProvider,
		ITreeItemContentProvider,
		IItemLabelProvider,
		IItemPropertySource {
	
	/**
	 * @generated NOT
	 */
	public static final String STABLE_REGIONS_GROUP = "Stable Regions";

	/**
	 * @generated NOT
	 */
	public static final String MODEL_CHECKING_GROUP = "Model Checking";

	/**
	 * @generated NOT
	 */
	public static final String EQUIVALENCE_GROUP = "Behavioral Equivalence";

	/**
	 * This constructs an instance from a factory and a notifier.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NetworkItemProvider(AdapterFactory adapterFactory) {
		super(adapterFactory);
	}

	/**
	 * This returns the property descriptors for the adapted class.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
		if (itemPropertyDescriptors == null) {
			super.getPropertyDescriptors(object);

			addCheckEquivalencePropertyDescriptor(object);
			addCheckModalFormulaPropertyDescriptor(object);
			addCheckStableRegionsPropertyDescriptor(object);
			addModalFormulaPropertyDescriptor(object);
			addStableRegionsPropertyDescriptor(object);
		}
		return itemPropertyDescriptors;
	}

	/**
	 * This adds a property descriptor for the Check Equivalence feature.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	protected void addCheckEquivalencePropertyDescriptor(Object object) {
		itemPropertyDescriptors.add
			(createItemPropertyDescriptor
				(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
				 getResourceLocator(),
				 getString("_UI_Network_checkEquivalence_feature"),
				 getString("_UI_PropertyDescriptor_description", "_UI_Network_checkEquivalence_feature", "_UI_Network_type"),
				 ArnePackage.Literals.NETWORK__CHECK_EQUIVALENCE,
				 true,
				 false,
				 false,
				 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
				 EQUIVALENCE_GROUP,
				 null));
	}

	/**
	 * This adds a property descriptor for the Check Modal Formula feature.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	protected void addCheckModalFormulaPropertyDescriptor(Object object) {
		itemPropertyDescriptors.add
			(createItemPropertyDescriptor
				(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
				 getResourceLocator(),
				 getString("_UI_Network_checkModalFormula_feature"),
				 getString("_UI_PropertyDescriptor_description", "_UI_Network_checkModalFormula_feature", "_UI_Network_type"),
				 ArnePackage.Literals.NETWORK__CHECK_MODAL_FORMULA,
				 true,
				 false,
				 false,
				 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
				 MODEL_CHECKING_GROUP,
				 null));
	}

	/**
	 * This adds a property descriptor for the Check Stable Regions feature.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	protected void addCheckStableRegionsPropertyDescriptor(Object object) {
		itemPropertyDescriptors.add
			(createItemPropertyDescriptor
				(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
				 getResourceLocator(),
				 getString("_UI_Network_checkStableRegions_feature"),
				 getString("_UI_PropertyDescriptor_description", "_UI_Network_checkStableRegions_feature", "_UI_Network_type"),
				 ArnePackage.Literals.NETWORK__CHECK_STABLE_REGIONS,
				 true,
				 false,
				 false,
				 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
				 STABLE_REGIONS_GROUP,
				 null));
	}

	/**
	 * This adds a property descriptor for the Modal Formula feature.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	protected void addModalFormulaPropertyDescriptor(Object object) {
		itemPropertyDescriptors.add
			(createItemPropertyDescriptor
				(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
				 getResourceLocator(),
				 getString("_UI_Network_modalFormula_feature"),
				 getString("_UI_PropertyDescriptor_description", "_UI_Network_modalFormula_feature", "_UI_Network_type"),
				 ArnePackage.Literals.NETWORK__MODAL_FORMULA,
				 true,
				 true,
				 false,
				 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
				 MODEL_CHECKING_GROUP,
				 null));
	}

	/**
	 * This adds a property descriptor for the Stable Regions feature.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	protected void addStableRegionsPropertyDescriptor(Object object) {
		itemPropertyDescriptors.add
			(createItemPropertyDescriptor
				(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
				 getResourceLocator(),
				 getString("_UI_Network_stableRegions_feature"),
				 getString("_UI_PropertyDescriptor_description", "_UI_Network_stableRegions_feature", "_UI_Network_type"),
				 ArnePackage.Literals.NETWORK__STABLE_REGIONS,
				 true,
				 false,
				 false,
				 ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE,
				 STABLE_REGIONS_GROUP,
				 null));
	}

	/**
	 * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
	 * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
	 * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
		if (childrenFeatures == null) {
			super.getChildrenFeatures(object);
			childrenFeatures.add(ArnePackage.Literals.NETWORK__NODES);
			childrenFeatures.add(ArnePackage.Literals.NETWORK__EDGES);
			childrenFeatures.add(ArnePackage.Literals.NETWORK__ACTIVATIONS);
		}
		return childrenFeatures;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EStructuralFeature getChildFeature(Object object, Object child) {
		// Check the type of the specified child object and return the proper feature to use for
		// adding (see {@link AddCommand}) it as a child.

		return super.getChildFeature(object, child);
	}

	/**
	 * This returns Network.gif.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object getImage(Object object) {
		return overlayImage(object, getResourceLocator().getImage("full/obj16/Network"));
	}

	/**
	 * This returns the label text for the adapted class.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String getText(Object object) {
		Network network = (Network)object;
		return getString("_UI_Network_type") + " " + network.isCheckEquivalence();
	}

	/**
	 * This handles model notifications by calling {@link #updateChildren} to update any cached
	 * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void notifyChanged(Notification notification) {
		updateChildren(notification);

		switch (notification.getFeatureID(Network.class)) {
			case ArnePackage.NETWORK__CHECK_EQUIVALENCE:
			case ArnePackage.NETWORK__CHECK_MODAL_FORMULA:
			case ArnePackage.NETWORK__CHECK_STABLE_REGIONS:
			case ArnePackage.NETWORK__MODAL_FORMULA:
			case ArnePackage.NETWORK__STABLE_REGIONS:
				fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
				return;
			case ArnePackage.NETWORK__NODES:
			case ArnePackage.NETWORK__EDGES:
			case ArnePackage.NETWORK__ACTIVATIONS:
				fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
				return;
		}
		super.notifyChanged(notification);
	}

	/**
	 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
	 * that can be created under this object.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
		super.collectNewChildDescriptors(newChildDescriptors, object);

		newChildDescriptors.add
			(createChildParameter
				(ArnePackage.Literals.NETWORK__NODES,
				 ArneFactory.eINSTANCE.createNode()));

		newChildDescriptors.add
			(createChildParameter
				(ArnePackage.Literals.NETWORK__EDGES,
				 ArneFactory.eINSTANCE.createEdge()));

		newChildDescriptors.add
			(createChildParameter
				(ArnePackage.Literals.NETWORK__ACTIVATIONS,
				 ArneFactory.eINSTANCE.createNetworkActivation()));
	}

	/**
	 * Return the resource locator for this item provider's resources.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public ResourceLocator getResourceLocator() {
		return ArneEditPlugin.INSTANCE;
	}

}
